package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    private IFollowService followService;

    //判断当前用户是否关注发布博客的用户
    /**
     * 是否关注用户
     *
     * @param followUserId 关注用户的id
     * @return
     */
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId) {
        return followService.isFollow(followUserId);
    }

    /**
     * 关注用户
     *
     * @param id       用户的id
     * @param isFollow 是否关注 true表示关注 false表示取关
     * @return
     */
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable Long id, @PathVariable Boolean isFollow) {
        return followService.follow(id, isFollow);
    }

    //查看共同关注
    @GetMapping("/common/{id}")
    public  Result getCommonUsers(@PathVariable Long id){
        return followService.showCommonUsers(id);
    }

}
